// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using Microsoft.Pex.Engine;
using Microsoft.Pex.Engine.Utilities;
using Microsoft.ExtendedReflection.Monitoring;
using Microsoft.ExtendedReflection.Utilities;
using System.IO;

namespace DySy.Integration
{
    /// <summary>
    /// Summary description for IntegrationTest
    /// </summary>
    [TestClass]
    public class DySyIntegrationTest
    {
        [TestMethod]
        public void DySy()
        {
            PexEngineOptions options = PexEngineOptions.CreateDefault();
            options.DoNotOpenReport = true;
            options.CompileTestProject = true;
            options.TestNoPartialClasses = true;
            options.Assembly = Path.GetFileName(typeof(DySyIntegrationTest).Assembly.Location);

            string binaryDirectory = Path.GetDirectoryName(typeof(DySyIntegrationTest).Assembly.Location);

            string arguments = String.Join(" ", options.GetCommandLineArguments(true));
            ProcessHelper p = new ProcessHelper("dysy", Path.Combine(binaryDirectory, "pex.exe") );
            p.AppendSwitch(arguments);
            p.WorkingDirectory = binaryDirectory;

            Console.WriteLine("{0}> {1}", p.WorkingDirectory, p.Command);
            if (!p.Execute())
            {
                int exitCode = p.ExitCode;
                Console.WriteLine("exit code {0} - {1}", exitCode, PexExitCodes.Describe(exitCode));
                Assert.AreEqual(PexExitCodes.Success, exitCode);
            }
        }
    }
}
